/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrameTemplate.java
 *
 * Created on 3-mar-2011, 17.11.21
 */

package presentation;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

/**
 *
 * @author quirino
 */
public class PFrameTemplate extends javax.swing.JFrame {

    /** Creates new form FrameTemplate */
    public PFrameTemplate() {
        initComponents();
        this.setPanels();
        this.getContentPane().setBackground(new Color(142,73,23));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        centerPanel = new javax.swing.JPanel();
        topLeftPanel = new javax.swing.JPanel();
        topRightPanel = new javax.swing.JPanel();
        leftPanel = new javax.swing.JPanel();
        bottomPanel = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setAlwaysOnTop(true);
        setBackground(null);
        setForeground(new java.awt.Color(242, 242, 239));
        getContentPane().setLayout(new java.awt.GridBagLayout());

        centerPanel.setBackground(null);

        javax.swing.GroupLayout centerPanelLayout = new javax.swing.GroupLayout(centerPanel);
        centerPanel.setLayout(centerPanelLayout);
        centerPanelLayout.setHorizontalGroup(
            centerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 481, Short.MAX_VALUE)
        );
        centerPanelLayout.setVerticalGroup(
            centerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
        getContentPane().add(centerPanel, gridBagConstraints);

        javax.swing.GroupLayout topLeftPanelLayout = new javax.swing.GroupLayout(topLeftPanel);
        topLeftPanel.setLayout(topLeftPanelLayout);
        topLeftPanelLayout.setHorizontalGroup(
            topLeftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        topLeftPanelLayout.setVerticalGroup(
            topLeftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 10);
        getContentPane().add(topLeftPanel, gridBagConstraints);

        topRightPanel.setBackground(new java.awt.Color(27, 206, 79));

        javax.swing.GroupLayout topRightPanelLayout = new javax.swing.GroupLayout(topRightPanel);
        topRightPanel.setLayout(topRightPanelLayout);
        topRightPanelLayout.setHorizontalGroup(
            topRightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        topRightPanelLayout.setVerticalGroup(
            topRightPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 5);
        getContentPane().add(topRightPanel, gridBagConstraints);

        leftPanel.setBackground(null);

        javax.swing.GroupLayout leftPanelLayout = new javax.swing.GroupLayout(leftPanel);
        leftPanel.setLayout(leftPanelLayout);
        leftPanelLayout.setHorizontalGroup(
            leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        leftPanelLayout.setVerticalGroup(
            leftPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.gridheight = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 10);
        getContentPane().add(leftPanel, gridBagConstraints);

        bottomPanel.setBackground(new java.awt.Color(224, 240, 30));

        javax.swing.GroupLayout bottomPanelLayout = new javax.swing.GroupLayout(bottomPanel);
        bottomPanel.setLayout(bottomPanelLayout);
        bottomPanelLayout.setHorizontalGroup(
            bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 481, Short.MAX_VALUE)
        );
        bottomPanelLayout.setVerticalGroup(
            bottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 20, Short.MAX_VALUE)
        );

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.gridwidth = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 5);
        getContentPane().add(bottomPanel, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public JPanel getBottomPanel() {
        return bottomPanel;
    }

    public void setBottomPanel(JPanel bottomPanel) {
        this.bottomPanel = bottomPanel;
    }

    public JPanel getCenterPanel() {
        return centerPanel;
    }

    public void setCenterPanel(JPanel centerPanel) {
        this.centerPanel = centerPanel;
    }

    public JPanel getLeftPanel() {
        return leftPanel;
    }

    public void setLeftPanel(JPanel leftPanel) {
        this.leftPanel = leftPanel;
    }

    public JPanel getTopLeftPanel() {
        return topLeftPanel;
    }

    public void setTopLeftPanel(JPanel topLeftPanel) {
        this.topLeftPanel = topLeftPanel;
    }

    public JPanel getTopRightPanel() {
        return topRightPanel;
    }

    public void setTopRightPanel(JPanel topRightPanel) {
        this.topRightPanel = topRightPanel;
    }

    /**
    * @param args the command line arguments
    */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel bottomPanel;
    private javax.swing.JPanel centerPanel;
    private javax.swing.JPanel leftPanel;
    private javax.swing.JPanel topLeftPanel;
    private javax.swing.JPanel topRightPanel;
    // End of variables declaration//GEN-END:variables

    public JButton getButtonExit() {
        return buttonExit;
    }

    public JPanel getWrapperTopLeft() {
        return wrapperTopLeft;
    }
    public JLabel getLabelTooltip() {
        return labelTooltip;
    }

    public JLayeredPane getWrapperLeft() {
        return wrapperLeft;
    }
    public void setLabelTooltip(JLabel labelTooltip) {
        this.labelTooltip = labelTooltip;
    }

    public void setWrapperLeft(PPanelTemplate wrapperLeft) {
        this.wrapperLeft = wrapperLeft;
    }

    public void setWrapperTopLeft(JPanel wrapperTopLeft) {
        this.wrapperTopLeft = wrapperTopLeft;
    }

    public void setWrapperTooltip(JLayeredPane wrapperTooltip) {
        this.wrapperTooltip = wrapperTooltip;
    }

    public JLayeredPane getWrapperTooltip() {
        return wrapperTooltip;
    }
    // End of variables declaration
    private JPanel wrapperTopLeft;
    private PPanelTemplate wrapperLeft;
    private PPanelTemplate wrapperCenter;
    private PPanelTemplate wrapperTopRight;
    private JButton buttonExit;
    private JButton buttonContattaPersona;
    private JButton buttonInviaFoto;
    private JButton buttonGestisciRubrica;
    private JButton buttonGestisciFoto;
    private JLabel labelTooltip;
    private JLayeredPane wrapperTooltip;
    private JLayeredPane leftMenu;
    private PUtility pu;

    public void setPanels(){
        this.pu= new PUtility();

        this.initTopLeftPanel();
        this.initLeftPanel();
        this.initCenterPanel();
        this.initTopRight();
    }

    public void initTopRight(){
        this.topRightPanel.setLayout(new BorderLayout());
        //this.topRightPanel.setBackground(null);

        //this.wrapperTopRight = new PPanelTemplate("src/images/bckTopPanel.png");
        
        //this.topRightPanel.add(this.wrapperTopRight);
    }

    public void initCenterPanel(){
        this.centerPanel.setLayout(new BorderLayout());
        this.centerPanel.setBackground(null);

        this.wrapperCenter= new PPanelTemplate("src/images/bckBacheca.png");

        this.centerPanel.add(this.wrapperCenter);
    }
    
    public void initTopLeftPanel(){
        this.topLeftPanel.setLayout(new FlowLayout());
        this.pu.removePaddingPanelFlow(this.topLeftPanel);
        this.topLeftPanel.setBackground(null);

        this.wrapperTopLeft= new JPanel();
        this.wrapperTopLeft.setBackground(null);
        this.pu.removePaddingPanelFlow(this.wrapperTopLeft);
        this.topLeftPanel.add(this.wrapperTopLeft);
        
        this.buttonExit= new JButton();
        this.buttonExit.setPreferredSize(new Dimension(200,70));
        this.wrapperTopLeft.add(this.buttonExit);
        this.buttonExit= this.pu.createButtonPersonalizzato(this.buttonExit,
                "src/images/esci.png", "src/images/esci_hover.png",
                "src/images/esci_mousedown.png", null);
    }

    public void initLeftPanel(){

        this.leftPanel.setLayout(new BorderLayout());
        this.leftPanel.setBackground(null);
        
        this.wrapperLeft= new PPanelTemplate("src/images/bckLeftPanel.png");

        this.leftPanel.add(this.wrapperLeft);

        this.initLeftMenu();

        this.wrapperTooltip= new JLayeredPane();
        this.wrapperTooltip.setBackground(null);
        
        this.labelTooltip= new JLabel("Tooltip");
        this.labelTooltip.setOpaque(false);
        this.wrapperTooltip.add(this.labelTooltip);
        
        this.wrapperLeft.setLayout(new GridBagLayout());
        GridBagConstraints gbc= new GridBagConstraints();
        
        gbc.fill= gbc.BOTH;
        gbc.gridheight= 1;
        gbc.gridwidth= 1;
        gbc.gridx= 0;
        gbc.gridy= 0;
        gbc.weightx= 1;
        gbc.weighty= 0;
        this.wrapperLeft.add(this.leftMenu, gbc);
        
        gbc.fill= gbc.BOTH;
        gbc.gridheight= 1;
        gbc.gridwidth= 2;
        gbc.gridx= 0;
        gbc.gridy= 2;
        gbc.weightx= 1;
        gbc.weighty= 1;
        this.wrapperLeft.add(this.wrapperTooltip, gbc);

    }

    private void initLeftMenu(){
        this.leftMenu= new JLayeredPane();
        this.leftMenu.setBackground(null);
        this.leftMenu.setLayout(new BoxLayout(this.leftMenu, BoxLayout.Y_AXIS));
        this.leftMenu.add(Box.createVerticalStrut(30));

        this.buttonContattaPersona= new JButton();
        this.buttonContattaPersona.setPreferredSize(new Dimension(170,80));
        this.buttonContattaPersona= this.pu.createButtonPersonalizzato(this.buttonContattaPersona,
                "src/images/butContattaPersona.png", "src/images/butContattaPersona.png",
                "src/images/butContattaPersona.png", null);
        this.leftMenu.add(this.buttonContattaPersona);
        this.leftMenu.add(Box.createVerticalStrut(5));

        this.buttonInviaFoto= new JButton();
        this.buttonInviaFoto.setPreferredSize(new Dimension(170,80));
        this.leftMenu.add(this.buttonInviaFoto);
        this.buttonInviaFoto= this.pu.createButtonPersonalizzato(this.buttonInviaFoto,
                "src/images/butInviaFoto.png", "src/images/butInviaFoto.png",
                "src/images/butInviaFoto.png", null);
        this.leftMenu.add(Box.createVerticalStrut(5));

        this.buttonGestisciRubrica= new JButton();
        this.buttonGestisciRubrica.setPreferredSize(new Dimension(170,80));
        this.leftMenu.add(this.buttonGestisciRubrica);
        this.buttonGestisciRubrica= this.pu.createButtonPersonalizzato(this.buttonGestisciRubrica,
                "src/images/butGestisciRubrica.png", "src/images/butGestisciRubrica.png",
                "src/images/butGestisciRubrica.png", null);

        this.leftMenu.add(Box.createVerticalStrut(5));

        this.buttonGestisciFoto= new JButton();
        this.buttonGestisciFoto.setPreferredSize(new Dimension(170,80));
        this.leftMenu.add(this.buttonGestisciFoto);
        this.buttonGestisciFoto= this.pu.createButtonPersonalizzato(this.buttonGestisciFoto,
                "src/images/butGestisciFoto.png", "src/images/butGestisciFoto.png",
                "src/images/butGestisciFoto.png", null);

        this.leftMenu.add(Box.createVerticalStrut(10));
    }
}
